import {Route} from 'react-router-dom';
import {getToken} from "../utils/cookies";
import Login from "../views/login";

export const PrivateRouter = ({component:Component,...res})=>{
    const handleRender = ()=>{
       /* if( getToken() ){
            return Component
        }else{
            if( res.computedMatch.path === '/' ){
                return Login
            }else{
                return Component
            }
        }*/
        return getToken() ? Component : Login;
    }
    return (
        <Route
            {...res}
            render={ ()=> <Route component={handleRender()} />}
        />
    )
}
